var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("BaseClick"),
    p = cc._decorator,
    l = p.ccclass,
    d = p.property,
    u =
        (p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.boxBomSprite = null;
                e.boxTopSprite = null;
                e.nodeView = null;
                return e;
            }
            e.prototype.onLoad = function () {
                t.prototype.onLoad.call(this);
                this.checkKind();
                EVUIEffView.on(EVUIEffView.checkCostUI, this.checkKind.bind(this), this);
                EVUIEffView.on(EVUIEffView.updateBoxCount, this.checkOpenDlg.bind(this), this);
                this.checkOpenDlg();
            };
            e.prototype.checkKind = function () {
                GuildCache.isOverOnceGuid(GuildCache.oncecheckId[1][1]) && GameDataValue.getLastLv() > 1
                    ? (this.node.active = !0)
                    : (this.node.active = !1);
                GuildCache.isOverOnceGuid(GuildCache.oncecheckId[1][1]) &&
                    !GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][0]) &&
                    (GameDataValue.haveNewTip()
                        ? EVUIEffView.on(EVUIEffView.checkRed, this.checkOpenGuild.bind(this), this)
                        : this.checkOpenGuild());
            };
            e.prototype.checkOpenDlg = function () {
                this.nodeView.active = !1;
                if (this.haveRewawrdKey("20002")) {
                    this.nodeView.active = !0;
                    SpriteView.setBoxBottom(2, this.boxBomSprite);
                    SpriteView.setBoxTop(2, this.boxTopSprite);
                } else if (this.haveRewawrdKey("20003")) {
                    this.nodeView.active = !0;
                    SpriteView.setBoxBottom(3, this.boxBomSprite);
                    SpriteView.setBoxTop(3, this.boxTopSprite);
                } else if (this.checkTime()) {
                    this.nodeView.active = !0;
                    SpriteView.setBoxBottom(1, this.boxBomSprite);
                    SpriteView.setBoxTop(1, this.boxTopSprite);
                }
            };
            e.prototype.checkTime = function () {
                var t = GameDataValue.getShopTimeCount(1, 0),
                    e = CacheDataManager.getShopDataCof().shop[20001];
                if (e) {
                    var o = Date.now() - t,
                        a = e.time_cd || 0;
                    console.log("ClickShop ----------------- aaaaaaaaaaaa");
                    return o >= 1e3 * a;
                }
                return !1;
            };
            e.prototype.haveRewawrdKey = function (t) {
                var e = CacheDataManager.getShopDataCof().shop[t];
                return !!e && GameDataValue.getShopKey(e.cost_item) >= (e.cost_num || 0);
            };
            e.prototype.checkOpenGuild = function () {
                !GameDataValue.haveNewTip() && GameDataValue.getLastLv() > 1 && this.openGuild();
            };
            e.prototype.onDestroy = function () {
                EVUIEffView.offTarget(this);
                t.prototype.onDestroy.call(this);
            };
            e.prototype.clickTask = function () {
                this._TouchStart(null);
            };
            e.prototype._TouchStart = function () {
                this.openShop();
            };
            e.prototype.openShop = function () {
                QAudio.play(QAudio.ui_button);
                s.default.open(r.UIID.UIShop);
            };
            e.prototype.openGuild = function () {
                if (!GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][0])) {
                    GuildCache.checkKey = GuildCache.oncecheckId[2][0];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[2][0]);
                    GuildCache.openGuildView();
                }
            };
            n([d(cc.Sprite)], e.prototype, "boxBomSprite", void 0);
            n([d(cc.Sprite)], e.prototype, "boxTopSprite", void 0);
            n([d(cc.Node)], e.prototype, "nodeView", void 0);
            return n([l], e);
        })(c.default));
o.default = u;
